Skip to content

Replace escaped surrogates in CSS with U+FFFD - #274

Merged
eXpl0it3r merged 1 commit into
masterfrom
fix/css-surrogate-escape
Nov 10, 2026
Merged

eXpl0it3r merged 1 commit into
masterfrom
fix/css-surrogate-escape

Conversation

@eXpl0it3r

Copy link
Copy Markdown
Collaborator

A CSS escape for the first or last surrogate code point, e.g. content: "\D800" or .a\DFFF { }, throws an ArgumentOutOfRangeException in the lexer and the whole document fails to load. CSS Syntax 3 says that zero, a surrogate or anything above U+10FFFF becomes U+FFFD instead. The range check in IsInvalid() compared against 0xD800 and 0xDFFF exclusively, so the two boundaries slipped through and ended up in char.ConvertFromUtf32, which rejects them. The check is now inclusive, zero and code points above U+10FFFF were already handled correctly.

How to test this PR?

CI should succeed. LexerInvalidEscapedCodePointInString and LexerInvalidEscapedCodePointInIdent cover zero, the surrogate range, the values right next to it and code points above U+10FFFF, the \D800 and \DFFF cases fail on master.

@eXpl0it3r
eXpl0it3r force-pushed the fix/css-surrogate-escape branch from f582e8c to 74c4618 Compare November 10, 2026 19:06
@eXpl0it3r
eXpl0it3r merged commit 62eeaf8 into master Nov 10, 2026
18 checks passed
@eXpl0it3r
eXpl0it3r deleted the fix/css-surrogate-escape branch November 10, 2026 19:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant